package com.cet.designpatterns.interpreter.cc;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @program: algorithm
 * @description: 终结符表达式
 * @author: 陈恩涛
 * @create: 2021-09-26 11:04
 **/
public class TerminalExpression implements Expression {

    private Set<String> set;

    public TerminalExpression(List<String> data) {
        set = new HashSet<>(data);
    }

    /**
     * 对于传入的info包含在该终结符表达式中维护的set中，interpret操作返回true
     * @param info
     * @return
     */
    @Override
    public boolean interpret(String info) {
        return set.contains(info);
    }
}
